<#include "common/main.html">
<#macro bodyId>user-mg</#macro>
<#macro content>

<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ty-common-page">
    <h1 class="page-header">用户列表
        <div class="btns">
            <a class="btn btn-success" href="${rc.contextPath}/user/gotoAdd">新增用户</a>
        </div>
    </h1>
    <div class="tool-bar">
        <div class="filter">
            <form method="get">
                <div class="form-group">
                    <div class="col-sm-12">
                        <div class="col5">
                            <span class="label-text">用户id：</span>
                            <input class="form-control" name="id" value="${userDto.id}"/>
                        </div>
                        <div class="col5">
                            <span class="label-text">账号：</span>
                            <input class="form-control" name="loginName" value="${userDto.loginName}"/>
                        </div>
                        <div class="col5">
                            <span class="label-text">功能角色：</span>
                            <select class="form-control" name="roleId">
                                <option></option>
                                <#list roleList as role>
                                <option value="${role.id}" ${(role.id==userDto.roleId)?string('selected','')}>${role.name}</option>
                                </#list>
                            </select>
                        </div>
                        <button class="btn btn-success">筛选</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>用户id</th>
                <th>账号</th>
                <th>用户姓名</th>
                <th>功能角色</th>
                <th class="date">创建日期</th>
                <th class="state">状态</th>
                <th class="operation">操作</th>
            </tr>
            </thead>
            <tbody>
            	<#list userList as user>
	            <tr data-id="${user.id}" data-userData='{"id":${user.id}, "loginName":"${user.loginName}", "name":"${user.name}", "loginPwd":"${user.loginPwd}"}'>
	            	<td>${user.id}</td>
	                <td>${user.loginName}</td>
	                <td>${user.name}</td>
	                <td>${user.roleNames}</td>
	                <td>${user.createTime?number?number_to_datetime?string("yyyy-MM-dd HH:mm")}</td>
	                <td class="state" data-state="${(user.enableStatus==1)?string('online','offline')}">${(user.enableStatus==1)?string('启用','禁用')}</td>
	                <td class="operation">
                        <div class="dropdown">
                            <a  class="J_edit" data-toggle="dropdown" href="#">修改 <span class="caret"></span></a>
                            <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                                <li class="edit"><a href="${rc.contextPath}/user/gotoUpdate?userId=${user.id}"  class="btn">修改</a></li>
                                <li class="${(user.enableStatus==1)?string('offline','online')}"><a href="#" data-id="${user.id}">${(user.enableStatus==1)?string('禁用','启用')}</a></li>
                            </ul>
                        </div>
                    </td>
                   
	            </tr>
	            </#list>
            </tbody>
        </table>
    </div>
    <#include "common/page.html">
</div>

<script>
    var config = {
        deleteById: "${rc.contextPath}/user/delete",
        updateOnlineStatus: "${rc.contextPath}/user/updateState"
    }
</script>
</#macro>